package hu;

import java.util.*;

public class packet_cs {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        char[] ch = input.toCharArray();
        Stack<String> stack = new Stack<>();
        for (int i = 0; i < input.length(); i++) {
            int t = i;
            while(ch[i] <= '9' && ch[i] >= '0'){
                i++;
            }
            stack.push(input.substring(t, i));
            if (ch[i] != ']')
                stack.push(String.valueOf(ch[i]));
            else{
                StringBuilder sb = new StringBuilder();
                while (!stack.isEmpty()) {
                    String str = stack.pop();
                    if (!str.equals("[")) {
                        sb.append(str);
                    } else {
                        int a = Integer.parseInt(stack.pop());
                        StringBuilder sb1 = new StringBuilder();
                        for (int j = 0; j < a; j++) {
                            sb1.append(sb);
                        }
                        stack.push(sb1.toString());
                        break;
                    }
                }
            }
        }
        String result = "";
        while(!stack.isEmpty()){
            result += stack.pop();
        }
        for (int i = result.length() - 1; i >= 0; i--) {
            System.out.print(result.charAt(i));
        }
    }
}
